package com.hzit.controller;

import com.hzit.dto.UserDto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Controller
@RequestMapping("/user")
public class UserController {

	//1. 用户登录
	@GetMapping("/login")
	public String login(String username, String password, HttpSession session){
		if("admin".equals(username) && "123".equals(password)){
			//1.1 构造一个UserDto对象
			UserDto dto = new UserDto(username,password);
			//1.2 将UserDto对象放到session中
			session.setAttribute("user",dto);
			//1.3 跳转到成功页面
			return "success";
		}
		return "redirect:/login.jsp";

	}
}
